/* globals emp */
/* dependancies :{
		"jquery" :"~1.9.2",
		"namespace":"0.0.1"
	}
*/
/**
 * @namespace configManager
 * @memberOf emp
 */
emp.configManager = (function () {
	var onloadCallback;

	/* Configuration setting vars and functions*/
	/**
	 * @memberof emp.configManager
	 * @method
	 * @protected
	 * @param  {object} args
	 * @return {void}
	 */
	function getConfig(args) {
		emp.$.ajax({
			type: "GET",
			url: args.path,
			success: function (data) {
				emp.configManager.config = data;
				if (args.callback != undefined){
					args.callback();
				}
			},
			failure: function (data) {
				alert("FAILURE could NOT find map configuration");
			},
			async: args.isSync
		});
	}
	/**
	 * @memberOf emp.configManager
	 * @protected
	 * @method
	 * @param  {object} args
	 * @return {void}
	 */
	function load(args) {
		if (typeof args.isSync === "undefined" || args.isSync === "" || args.isSync === null) {
			args.isSync = false; // EMP-272
		}
		getConfig(args.isSync, args.callback);
	}
	/* End private space */

	// Declare public functions and varibales within the publicInterface object
	//   this object is returned as emp.configManager 
	/**
	 * @memberOf emp.configManager
	 *
	 * @type {Object}
	 */
	var publicInterface = {
		/**
		 * @method
		 * @memberOf emp.configManager
		 * @param isSync boolean that dictates if the object will be built  asynchronously
		 * @desc Provides a Synchronous method -- blocks thread until object is fully populated.
		 * 		 Asnychronous method -- non-blocking, object is populated when async callbacks
		 * 		 are completed successfully.
		 *       False by default.
		 *
		 */
		load: function (args) {
			if (typeof args.isSync === 'undefined' || args.isSync == '' || args.isSync == null) {
				args.isSync = false;
			}
			getConfig(args);
		},
		/**
		 * @method
		 * @memberOf emp.configManager
		 * @return {void}
		 */
		loadComplete: function () {
			onloadCallback();
		}

	};
	return publicInterface;
}());